package com.ysjy.course.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wkbb.common.handler.JsonUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@ApiModel("托管服务")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class YsTrusteeship implements Serializable {
    @ApiModelProperty("是否已开班")
    private Boolean useClass;
    @ApiModelProperty(value = "班级关联ID")
    private Long classId;
    @ApiModelProperty("课程分类")
    private String tagName;
    @ApiModelProperty("场地名称")
    private String siteName;

    @ApiModelProperty("ID")
    private Long id;
    @ApiModelProperty("唯一标识")
    private String uniqueId;
    @ApiModelProperty("课程名称")
    private String title;
    @ApiModelProperty("封面")
    private String logo;
    @ApiModelProperty("服务形式 1上午半托 2下午半托 3全托")
    private Integer type;
    @ApiModelProperty("分类ID")
    private String tagId;
    @ApiModelProperty("场地ID")
    private Long siteId;
    @ApiModelProperty("适合年级ID 多个','分割(注：所有年级为`0`)")
    private String gradeIds;
    @ApiModelProperty("适合年级 多个','分割(注：所有年级为`全部`)")
    private String gradeNames;
    @ApiModelProperty("服务内容")
    private String content;
    @ApiModelProperty("总金额(分)")
    private Integer amount;
    @ApiModelProperty("服务年份")
    private String serviceYear;
    @ApiModelProperty("最大报名人数")
    private Integer maxSignUpNum;
    @ApiModelProperty("服务频率、时间 多个','分隔")
    private String classTime;
    @ApiModelProperty("服务开始时间")
    private Date startTime;
    @ApiModelProperty("服务结束时间")
    private Date endTime;
    @ApiModelProperty("报名开始时间")
    private Date signUpStartTime;
    @ApiModelProperty("报名结束时间")
    private Date signUpEndTime;
    @ApiModelProperty("上架机构（学校）id列表（多个,逗号隔开）")
    private String orgIds;
    @ApiModelProperty("上架机构（学校）名称列表")
    private String orgNames;
    @ApiModelProperty("状态 1启用 0禁用")
    private Boolean enabled;
    @ApiModelProperty("更新时间")
    private Date updateTime;
    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("已报名数")
    private Integer signUpNum;
    @ApiModelProperty("报名状态 0未开始、1报名中、2已结束、3已报名、4已报满")
    private Integer signUpStatus;
    @ApiModelProperty("上架状态：0未上架 1上架")
    private Integer shelvesStatus;
    @ApiModelProperty("授课老师")
    private Long teacherId;
    @ApiModelProperty("授课老师")
    private String teacherName;
    @ApiModelProperty("上架时间")
    private Date shelvesTime;

    public void initSignUpStatus() {
        if (signUpStatus != null || signUpStartTime == null || signUpEndTime == null) return;
        if (signUpNum == null) signUpNum = 0;
        if (maxSignUpNum <= signUpNum) {
            signUpStatus = 4;
            return;
        }
        Date currDate = new Date();
        if (currDate.getTime() > signUpEndTime.getTime()) {
            signUpStatus = 2;
            return;
        }
        if (currDate.getTime() > signUpStartTime.getTime()) {
            signUpStatus = 1;
            return;
        }
        signUpStatus = 0;
    }

    public static void main(String[] args) {
        YsTrusteeship trusteeship = new YsTrusteeship();
        trusteeship.setAmount(1);
        trusteeship.setTitle("暑期托管1");
        trusteeship.setLogo("https://qiniu.childrenonline.cn/Fin5cd36X2FCZOPEaNhU0qZCpq-x");
        trusteeship.setType(3);
        trusteeship.setTagId("5");
        trusteeship.setOrgIds("1452");
        trusteeship.setOrgNames("紫城中学");
        trusteeship.setStartTime(new Date());
        trusteeship.setEndTime(new Date());
        trusteeship.setSignUpStartTime(new Date());
        trusteeship.setSignUpEndTime(new Date());
        trusteeship.setClassTime("星期三 09:00~10:00,星期五 09:00~10:00");
        trusteeship.setMaxSignUpNum(99);
        trusteeship.setServiceYear("2022");
        trusteeship.setContent("服务内容服务内容服务内容");
        System.out.println(JsonUtil.objectToJson(trusteeship));


    }
}
